/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entity;

import java.io.Serializable;
import java.math.BigInteger;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author WinKiQue58
 */
@Entity
@Table(name = "S3R4_ORDER")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "S3r4Order.findAll", query = "SELECT s FROM S3r4Order s"),
    @NamedQuery(name = "S3r4Order.findByIdOrder", query = "SELECT s FROM S3r4Order s WHERE s.s3r4OrderPK.idOrder = :idOrder"),
    @NamedQuery(name = "S3r4Order.findByIdPersonalInfo", query = "SELECT s FROM S3r4Order s WHERE s.s3r4OrderPK.idPersonalInfo = :idPersonalInfo"),
    @NamedQuery(name = "S3r4Order.findByIdBranchenterprise", query = "SELECT s FROM S3r4Order s WHERE s.s3r4OrderPK.idBranchenterprise = :idBranchenterprise"),
    @NamedQuery(name = "S3r4Order.findByIdEnterprise", query = "SELECT s FROM S3r4Order s WHERE s.s3r4OrderPK.idEnterprise = :idEnterprise"),
    @NamedQuery(name = "S3r4Order.findByNumitems", query = "SELECT s FROM S3r4Order s WHERE s.numitems = :numitems"),
    @NamedQuery(name = "S3r4Order.findByNumproducts", query = "SELECT s FROM S3r4Order s WHERE s.numproducts = :numproducts")})
public class S3r4Order implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected S3r4OrderPK s3r4OrderPK;
    @Column(name = "NUMITEMS")
    private Integer numitems;
    @Column(name = "NUMPRODUCTS")
    private Integer numproducts;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "s3r4Order", fetch = FetchType.LAZY)
    private List<OrderStatus> orderStatusList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "s3r4Order", fetch = FetchType.LAZY)
    private List<OrderItem> orderItemList;
    @JoinColumns({
        @JoinColumn(name = "ID_PERSONAL_INFO", referencedColumnName = "ID_PERSONAL_INFO", insertable = false, updatable = false),
        @JoinColumn(name = "ID_BRANCHENTERPRISE", referencedColumnName = "ID_BRANCHENTERPRISE", insertable = false, updatable = false),
        @JoinColumn(name = "ID_ENTERPRISE", referencedColumnName = "ID_ENTERPRISE", insertable = false, updatable = false)})
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private PersonalInfo personalInfo;

    public S3r4Order() {
    }

    public S3r4Order(S3r4OrderPK s3r4OrderPK) {
        this.s3r4OrderPK = s3r4OrderPK;
    }

    public S3r4Order(BigInteger idOrder, BigInteger idPersonalInfo, BigInteger idBranchenterprise, BigInteger idEnterprise) {
        this.s3r4OrderPK = new S3r4OrderPK(idOrder, idPersonalInfo, idBranchenterprise, idEnterprise);
    }

    public S3r4OrderPK getS3r4OrderPK() {
        return s3r4OrderPK;
    }

    public void setS3r4OrderPK(S3r4OrderPK s3r4OrderPK) {
        this.s3r4OrderPK = s3r4OrderPK;
    }

    public Integer getNumitems() {
        return numitems;
    }

    public void setNumitems(Integer numitems) {
        this.numitems = numitems;
    }

    public Integer getNumproducts() {
        return numproducts;
    }

    public void setNumproducts(Integer numproducts) {
        this.numproducts = numproducts;
    }

    @XmlTransient
    public List<OrderStatus> getOrderStatusList() {
        return orderStatusList;
    }

    public void setOrderStatusList(List<OrderStatus> orderStatusList) {
        this.orderStatusList = orderStatusList;
    }

    @XmlTransient
    public List<OrderItem> getOrderItemList() {
        return orderItemList;
    }

    public void setOrderItemList(List<OrderItem> orderItemList) {
        this.orderItemList = orderItemList;
    }

    public PersonalInfo getPersonalInfo() {
        return personalInfo;
    }

    public void setPersonalInfo(PersonalInfo personalInfo) {
        this.personalInfo = personalInfo;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (s3r4OrderPK != null ? s3r4OrderPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof S3r4Order)) {
            return false;
        }
        S3r4Order other = (S3r4Order) object;
        if ((this.s3r4OrderPK == null && other.s3r4OrderPK != null) || (this.s3r4OrderPK != null && !this.s3r4OrderPK.equals(other.s3r4OrderPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entity.S3r4Order[ s3r4OrderPK=" + s3r4OrderPK + " ]";
    }
    
}
